<?

	$accion = $_GET['a'];
	$id = $_GET['i'];
	$lobo = $_GET['l'];

	$c = mysql_connect('localhost','chileesm_lobo','nuhk@HgHTDO]') or die('error al conectar');
	mysql_select_db('chileesm_lobos',$c) or die('error al seleciconar la bd');

	if( $accion=='past' ){
		$rs = mysql_query( 'SELECT * FROM actividad WHERE lobo='.$lobo.' AND estado=1 ORDER BY ID ASC' , $c ) or die('error en la consulta past');
		$arr = array();
		while($r = mysql_fetch_assoc($rs)) { $arr[] = $r; }
		$list = json_encode($arr);
		mysql_free_result($rs);
		mysql_close();
		echo $list;
	}

	if( $accion=='current' ){
		$sql='SELECT * FROM actividad WHERE lobo='.$lobo.' AND estado=1 AND id > '.$id.' ORDER BY ID ASC LIMIT 0,1 ';
		$rs = mysql_query( $sql , $c ) or die('error en la consulta current ['.$sql.']');
		$arr = array();
		while($r = mysql_fetch_assoc($rs)) { $arr[] = $r; }
		$list = json_encode($arr);
		mysql_free_result($rs);
		mysql_close();
		echo $list;
	}

?>